package cranim.graphics;

import java.awt.Graphics2D;

/**
 * 
 * @author Benedikt
 */
public abstract class Entity {
    
    protected double x, y, middleX, middleY;
    protected Sprite sprite;

    public Entity(String ref, int x, int y, double scale) {
        this.sprite = SpriteStore.get().getSprite(ref, false, scale, 0);
        this.x = x;
        this.y = y;
        this.middleX = x + sprite.getWidth()/2;
        this.middleY = x + sprite.getHeight()/2;
    }
    
    public Entity(String ref,int x,int y, double scale, double rotate) {
        this.sprite = SpriteStore.get().getSprite(ref, true, scale, rotate);
        this.x = x;
        this.y = y;
    }

    public void draw(Graphics2D g) {
        sprite.draw(g,(int) x,(int) y);
    }

    public void setCoords(int x, int y){
        this.x = x;
        this.y = y;            
    }

    public int getX() {
        return (int) x;
    }

    public int getY() {
        return (int) y;
    }
    
    public int[] getMiddle(){
        int[] middle = {getX(), getY()};
        return middle;
    }
    
    public Sprite getSprite(){
        return sprite;
    }
	
}